<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Tag
 *
 * @property int $id
 * @property string $name
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property int $image_id
 * @property string $name_en
 * @property string $key_word
 * @property string $description
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Article[] $articles
 * @property-read mixed $site_url
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Show[] $shows
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereDescription($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereImageId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereKeyWord($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereName($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereNameEn($value)
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property string $deleted_at
 * @method static \Illuminate\Database\Query\Builder|\App\Tag whereDeletedAt($value)
 */
class Tag extends Model
{
    //
    protected $fillable = ['name','key_word','description'];


    public function articles() {
        return $this->belongsToMany('App\Article')->withTimestamps();
    }

    public function shows() {
        return $this->belongsToMany('App\Show');
    }

    public function getSiteUrlAttribute () {
        return env('APP_URL').'/tag/'.$this->id;
    }


}
